package org.jeecg.modules.xmss.service.impl;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.exceptions.ClientException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DySmsHelper;
import org.jeecg.common.util.FileUtils;
import org.jeecg.modules.system.controller.SysOperationLogController;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.system.util.DateUtil;
import org.jeecg.modules.system.vo.SysOperationLogPage;
import org.jeecg.modules.xmss.entity.XmssIdea;
import org.jeecg.modules.xmss.entity.XmssSupervise;
import org.jeecg.modules.xmss.entity.XmssTowns;
import org.jeecg.modules.xmss.mapper.XmssIdeaMapper;
import org.jeecg.modules.xmss.mapper.XmssSuperviseMapper;
import org.jeecg.modules.xmss.service.IXmssIdeaService;
import org.jeecg.modules.xmss.service.IXmssTownsService;
import org.jeecg.modules.xmss.vo.AccessTimeVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Description: 选民意见建议表
 * @Author: jeecg-boot
 * @Date: 2020-09-18
 * @Version: V1.0
 */
@Service
public class XmssIdeaServiceImpl extends ServiceImpl<XmssIdeaMapper, XmssIdea> implements IXmssIdeaService {

    @Autowired
    private XmssIdeaMapper xmssIdeaMapper;

    @Autowired
    private XmssSuperviseMapper xmssSuperviseMapper;

	@Autowired
	IXmssTownsService iXmssTownsService;

    @Autowired
    private SysOperationLogController sysOperationLogController;

	@Autowired
	private ISysUserService sysUserService;

    @Value("${jeecg.path.xmss}")
    private String dirPath;

    @Override
    @Transactional
    public void saveMain(XmssIdea xmssIdea) {
        xmssIdeaMapper.insert(xmssIdea);
    }

    @Override
    @Transactional
    public void updateMain(XmssIdea xmssIdea) {
        xmssIdeaMapper.updateById(xmssIdea);

        //1.先删除子表数据

        //2.子表数据重新插入
    }

    @Override
    @Transactional
    public void delMain(String id) {
        xmssIdeaMapper.deleteById(id);
    }

    @Override
    @Transactional
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for (Serializable id : idList) {
            xmssIdeaMapper.deleteById(id);
        }
    }

    @Override
    public void manageIdea(String id, Integer state, String content, String picture, Integer type,Integer answerType, Integer starDb,String userId) throws ClientException {
        //1评价  2回复  3整个驳回 4督办确认事件 5督办驳回 6交办确认事件 7交办驳回
        XmssIdea xmssIdea = getById(id);
        if (type.equals(1)) {
            xmssIdea.setSupervise(state);
            xmssIdea.setStarDb(starDb);
            xmssIdea.setAppState(4);
        }
        if (type.equals(2)) {
            xmssIdea.setAnswer(content);
            xmssIdea.setAnswerUrl(picture);
            xmssIdea.setAppState(3);
            xmssIdea.setAnswerTime(new Date());
			JSONObject obj = new JSONObject();
			//政府
			XmssTowns byId = iXmssTownsService.getById(xmssIdea.getTownsId());
			if(byId != null ){
				DySmsHelper.sendSmsZll(xmssIdea.getMobile(), obj, byId.getFinishTemplateCode(),byId.getSign());
			}
        }
        if (type.equals(3)) {
            xmssIdea.setAnswer(content);
            xmssIdea.setAppState(5);
            xmssIdea.setAnswerTime(new Date());
        }
        if (type.equals(4)) {
            xmssIdea.setIsRead(1);
            xmssIdea.setDbTime(new Date());
        }
        if (type.equals(5)) {
            xmssSuperviseMapper.deleteDbAndIdea(userId,id);
			//发送待处理短信
			JSONObject obj = new JSONObject();
			obj.put("name", sysUserService.getById(userId).getRealname());
			//乡镇
			XmssTowns xmssTowns = iXmssTownsService.getById(xmssIdea.getTownsId());
			if(StringUtils.isNotEmpty(xmssTowns.getRefuseTemplateCode())){
				List<SysUser> xz = sysUserService.getUserListByDx(xmssIdea.getTownsId(), "2");
				for (int i = 0; i < xz.size(); i++) {
					DySmsHelper.sendSmsZll(xz.get(i).getPhone(), obj, xmssTowns.getTodoTemplateCode(),xmssTowns.getSign());
				}
			}
        }
        if (type.equals(6)) {
            xmssIdea.setAppState(2);
			xmssIdea.setDealTime(new Date());
        }
        if (type.equals(7)) {
			xmssSuperviseMapper.deleteJbAndIdea(userId,id);
			//发送待处理短信
			JSONObject obj = new JSONObject();
			obj.put("name", sysUserService.getById(userId).getRealname());
			//乡镇
			XmssTowns xmssTowns = iXmssTownsService.getById(xmssIdea.getTownsId());
			if(StringUtils.isNotEmpty(xmssTowns.getRefuseTemplateCode())){
				List<SysUser> xz = sysUserService.getUserListByDx(xmssIdea.getTownsId(), "2");
				for (int i = 0; i < xz.size(); i++) {
					DySmsHelper.sendSmsZll(xz.get(i).getPhone(), obj, xmssTowns.getTodoTemplateCode(),xmssTowns.getSign());
				}
			}
        }
		xmssIdea.setAnswerType(answerType);
        xmssIdea.setUpdateTime(new Date());
        updateById(xmssIdea);

    }

    @Override
    public Map<String, Object> thingData(int type) {
        Map<String, Object> map = new HashMap<>();

		map.put("success", true);
		map.put("message", "操作成功!");
		map.put("code", "200");
		List<Object> result = new ArrayList<>();
		List<Object> time = new ArrayList<>();
		String now = DateUtil.getTime();
		//周
		Map<String, Object> dt = null;
		Map<String, Object> dt1 = null;
		dt = new HashMap<>();
		dt.put("name", "已办");
		dt1 = new HashMap<>();
		dt1.put("name", "未办");
		AccessTimeVo accessTimeVo = new AccessTimeVo();
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		accessTimeVo.setAreaCode(sysUser.getRelTenantIds());
		if (type == 1) {
			String x0 = DateUtil.getQianXday(0).substring(0, 10);
			String x1 = DateUtil.getQianXday(1).substring(0, 10);
			String x2 = DateUtil.getQianXday(2).substring(0, 10);
			String x3 = DateUtil.getQianXday(3).substring(0, 10);
			String x4 = DateUtil.getQianXday(4).substring(0, 10);
			String x5 = DateUtil.getQianXday(5).substring(0, 10);
			String x6 = DateUtil.getQianXday(6).substring(0, 10);

			accessTimeVo.setSt7(x6 + " 00:00:00");
			accessTimeVo.setEnd7(x6 + " 23:59:59");
			accessTimeVo.setSt6(x5 + " 00:00:00");
			accessTimeVo.setEnd6(x5 + " 23:59:59");
			accessTimeVo.setSt5(x4 + " 00:00:00");
			accessTimeVo.setEnd5(x4 + " 23:59:59");
			accessTimeVo.setSt4(x3 + " 00:00:00");
			accessTimeVo.setEnd4(x3 + " 23:59:59");
			accessTimeVo.setSt3(x2 + " 00:00:00");
			accessTimeVo.setEnd3(x2 + " 23:59:59");
			accessTimeVo.setSt2(x1 + " 00:00:00");
			accessTimeVo.setEnd2(x1 + " 23:59:59");
			accessTimeVo.setSt1(x0 + " 00:00:00");
			accessTimeVo.setEnd1(x0 + " 23:59:59");


			Map<String, String> map1 = xmssIdeaMapper.selectTimeByBan(accessTimeVo);
			Map<String, String> map2 = xmssIdeaMapper.selectTimeByNoBan(accessTimeVo);

			for (int i = 7; i > 0; i--) {

				if (map1 != null) {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), map1.get("t" + i));
				} else {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map2 != null) {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), map2.get("t" + i));
				} else {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				//dt.put("time", DateUtil.getQianXday(i).substring(5, 10));
				time.add(DateUtil.getQianXday(i-1).substring(5, 10));
			}
			result.add(dt);
			result.add(dt1);
			map.put("data", result);
			map.put("time", time);
		}

        //月
        if (type == 2) {

			String x0 = DateUtil.getQianXday(0).substring(0, 10);
			String x1 = DateUtil.getQianXday(1).substring(0, 10);
			String x2 = DateUtil.getQianXday(2).substring(0, 10);
			String x3 = DateUtil.getQianXday(3).substring(0, 10);
			String x4 = DateUtil.getQianXday(4).substring(0, 10);
			String x5 = DateUtil.getQianXday(5).substring(0, 10);
			String x6 = DateUtil.getQianXday(6).substring(0, 10);
			String x7 = DateUtil.getQianXday(7).substring(0, 10);
			String x8 = DateUtil.getQianXday(8).substring(0, 10);
			String x9 = DateUtil.getQianXday(9).substring(0, 10);
			String x10 = DateUtil.getQianXday(10).substring(0, 10);
			String x11 = DateUtil.getQianXday(11).substring(0, 10);
			String x12 = DateUtil.getQianXday(12).substring(0, 10);
			String x13 = DateUtil.getQianXday(13).substring(0, 10);
			String x14 = DateUtil.getQianXday(14).substring(0, 10);
			String x15 = DateUtil.getQianXday(15).substring(0, 10);
			String x16 = DateUtil.getQianXday(16).substring(0, 10);
			String x17 = DateUtil.getQianXday(17).substring(0, 10);
			String x18 = DateUtil.getQianXday(18).substring(0, 10);
			String x19 = DateUtil.getQianXday(19).substring(0, 10);
			String x20 = DateUtil.getQianXday(20).substring(0, 10);
			String x21 = DateUtil.getQianXday(21).substring(0, 10);
			String x22 = DateUtil.getQianXday(22).substring(0, 10);
			String x23 = DateUtil.getQianXday(23).substring(0, 10);
			String x24 = DateUtil.getQianXday(24).substring(0, 10);
			String x25 = DateUtil.getQianXday(25).substring(0, 10);
			String x26 = DateUtil.getQianXday(26).substring(0, 10);
			String x27 = DateUtil.getQianXday(27).substring(0, 10);
			String x28 = DateUtil.getQianXday(28).substring(0, 10);
			String x29 = DateUtil.getQianXday(29).substring(0, 10);
			String x30 = DateUtil.getQianXday(30).substring(0, 10);
			String x31 = DateUtil.getQianXday(30).substring(0, 10);
			/*accessTimeVo.setSt31(x31 + " 00:00:00");
			accessTimeVo.setEnd31(x31 + " 23:59:59");
			accessTimeVo.setSt30(x30 + " 00:00:00");
			accessTimeVo.setEnd30(x30 + " 23:59:59");
			accessTimeVo.setSt29(x29 + " 00:00:00");
			accessTimeVo.setEnd29(x29 + " 23:59:59");
			accessTimeVo.setSt28(x28 + " 00:00:00");
			accessTimeVo.setEnd28(x28 + " 23:59:59");
			accessTimeVo.setSt27(x27 + " 00:00:00");
			accessTimeVo.setEnd27(x27 + " 23:59:59");
			accessTimeVo.setSt26(x26 + " 00:00:00");
			accessTimeVo.setEnd26(x26 + " 23:59:59");
			accessTimeVo.setSt25(x25 + " 00:00:00");
			accessTimeVo.setEnd25(x25 + " 23:59:59");
			accessTimeVo.setSt24(x24 + " 00:00:00");
			accessTimeVo.setEnd24(x24 + " 23:59:59");
			accessTimeVo.setSt23(x23 + " 00:00:00");
			accessTimeVo.setEnd23(x23 + " 23:59:59");
			accessTimeVo.setSt22(x22 + " 00:00:00");
			accessTimeVo.setEnd22(x22 + " 23:59:59");
			accessTimeVo.setSt21(x21 + " 00:00:00");
			accessTimeVo.setEnd21(x21 + " 23:59:59");
			accessTimeVo.setSt20(x20 + " 00:00:00");
			accessTimeVo.setEnd20(x20 + " 23:59:59");


			accessTimeVo.setSt19(x19 + " 00:00:00");
			accessTimeVo.setEnd19(x19 + " 23:59:59");
			accessTimeVo.setSt18(x18 + " 00:00:00");
			accessTimeVo.setEnd18(x18 + " 23:59:59");
			accessTimeVo.setSt17(x17 + " 00:00:00");
			accessTimeVo.setEnd17(x17 + " 23:59:59");
			accessTimeVo.setSt16(x16 + " 00:00:00");
			accessTimeVo.setEnd16(x16 + " 23:59:59");
			accessTimeVo.setSt15(x15 + " 00:00:00");
			accessTimeVo.setEnd15(x15 + " 23:59:59");
			accessTimeVo.setSt14(x14 + " 00:00:00");
			accessTimeVo.setEnd14(x14 + " 23:59:59");
			accessTimeVo.setSt13(x13 + " 00:00:00");
			accessTimeVo.setEnd13(x13 + " 23:59:59");
			accessTimeVo.setSt12(x12 + " 00:00:00");
			accessTimeVo.setEnd12(x12 + " 23:59:59");
			accessTimeVo.setSt11(x11 + " 00:00:00");
			accessTimeVo.setEnd11(x11 + " 23:59:59");
			accessTimeVo.setSt10(x10 + " 00:00:00");
			accessTimeVo.setEnd10(x10 + " 23:59:59");


			accessTimeVo.setSt9(x9 + " 00:00:00");
			accessTimeVo.setEnd9(x9 + " 23:59:59");
			accessTimeVo.setSt8(x8 + " 00:00:00");
			accessTimeVo.setEnd8(x8 + " 23:59:59");
			accessTimeVo.setSt7(x7 + " 00:00:00");
			accessTimeVo.setEnd7(x7 + " 23:59:59");
			accessTimeVo.setSt6(x6 + " 00:00:00");
			accessTimeVo.setEnd6(x6 + " 23:59:59");
			accessTimeVo.setSt5(x5 + " 00:00:00");
			accessTimeVo.setEnd5(x5 + " 23:59:59");
			accessTimeVo.setSt4(x4 + " 00:00:00");
			accessTimeVo.setEnd4(x4 + " 23:59:59");
			accessTimeVo.setSt3(x3 + " 00:00:00");
			accessTimeVo.setEnd3(x3 + " 23:59:59");
			accessTimeVo.setSt2(x2 + " 00:00:00");
			accessTimeVo.setEnd2(x2 + " 23:59:59");
			accessTimeVo.setSt1(x1 + " 00:00:00");
			accessTimeVo.setEnd1(x1 + " 23:59:59");*/




			accessTimeVo.setSt31(x30 + " 00:00:00");
			accessTimeVo.setEnd31(x30 + " 23:59:59");
			accessTimeVo.setSt30(x29 + " 00:00:00");
			accessTimeVo.setEnd30(x29 + " 23:59:59");
			accessTimeVo.setSt29(x28 + " 00:00:00");
			accessTimeVo.setEnd29(x28 + " 23:59:59");
			accessTimeVo.setSt28(x27 + " 00:00:00");
			accessTimeVo.setEnd28(x27 + " 23:59:59");
			accessTimeVo.setSt27(x26 + " 00:00:00");
			accessTimeVo.setEnd27(x26 + " 23:59:59");
			accessTimeVo.setSt26(x25 + " 00:00:00");
			accessTimeVo.setEnd26(x25 + " 23:59:59");
			accessTimeVo.setSt25(x24 + " 00:00:00");
			accessTimeVo.setEnd25(x24 + " 23:59:59");
			accessTimeVo.setSt24(x23 + " 00:00:00");
			accessTimeVo.setEnd24(x23 + " 23:59:59");
			accessTimeVo.setSt23(x22 + " 00:00:00");
			accessTimeVo.setEnd23(x22 + " 23:59:59");
			accessTimeVo.setSt22(x21 + " 00:00:00");
			accessTimeVo.setEnd22(x21 + " 23:59:59");
			accessTimeVo.setSt21(x20 + " 00:00:00");
			accessTimeVo.setEnd21(x20 + " 23:59:59");
			accessTimeVo.setSt20(x19 + " 00:00:00");
			accessTimeVo.setEnd20(x19 + " 23:59:59");


			accessTimeVo.setSt19(x18 + " 00:00:00");
			accessTimeVo.setEnd19(x18 + " 23:59:59");
			accessTimeVo.setSt18(x17 + " 00:00:00");
			accessTimeVo.setEnd18(x17 + " 23:59:59");
			accessTimeVo.setSt17(x16 + " 00:00:00");
			accessTimeVo.setEnd17(x16 + " 23:59:59");
			accessTimeVo.setSt16(x15 + " 00:00:00");
			accessTimeVo.setEnd16(x15 + " 23:59:59");
			accessTimeVo.setSt15(x14 + " 00:00:00");
			accessTimeVo.setEnd15(x14 + " 23:59:59");
			accessTimeVo.setSt14(x13 + " 00:00:00");
			accessTimeVo.setEnd14(x13 + " 23:59:59");
			accessTimeVo.setSt13(x12 + " 00:00:00");
			accessTimeVo.setEnd13(x12 + " 23:59:59");
			accessTimeVo.setSt12(x11 + " 00:00:00");
			accessTimeVo.setEnd12(x11 + " 23:59:59");
			accessTimeVo.setSt11(x10 + " 00:00:00");
			accessTimeVo.setEnd11(x10 + " 23:59:59");
			accessTimeVo.setSt10(x9 + " 00:00:00");
			accessTimeVo.setEnd10(x9 + " 23:59:59");


			accessTimeVo.setSt9(x8 + " 00:00:00");
			accessTimeVo.setEnd9(x8 + " 23:59:59");
			accessTimeVo.setSt8(x7 + " 00:00:00");
			accessTimeVo.setEnd8(x7 + " 23:59:59");
			accessTimeVo.setSt7(x6 + " 00:00:00");
			accessTimeVo.setEnd7(x6 + " 23:59:59");
			accessTimeVo.setSt6(x5 + " 00:00:00");
			accessTimeVo.setEnd6(x5 + " 23:59:59");
			accessTimeVo.setSt5(x4 + " 00:00:00");
			accessTimeVo.setEnd5(x4 + " 23:59:59");
			accessTimeVo.setSt4(x3 + " 00:00:00");
			accessTimeVo.setEnd4(x3 + " 23:59:59");
			accessTimeVo.setSt3(x2 + " 00:00:00");
			accessTimeVo.setEnd3(x2 + " 23:59:59");
			accessTimeVo.setSt2(x1 + " 00:00:00");
			accessTimeVo.setEnd2(x1 + " 23:59:59");
			accessTimeVo.setSt1(x0 + " 00:00:00");
			accessTimeVo.setEnd1(x0 + " 23:59:59");


			Map<String, String> map1 = xmssIdeaMapper.selectTimeByBan(accessTimeVo);
			Map<String, String> map2 = xmssIdeaMapper.selectTimeByNoBan(accessTimeVo);

			for (int i = 31; i > 0; i--) {
				if (map1 != null) {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), map1.get("t" + i));
				} else {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map2 != null) {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), map2.get("t" + i));
				} else {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				time.add(DateUtil.getQianXday(i-1).substring(5, 10));

			}
			result.add(dt);
			result.add(dt1);
			map.put("data", result);
			map.put("time", time);
		}

		if (type == 3) {
			String xx = DateUtil.getQianMonth(-1).substring(0, 10);
			String x0 = DateUtil.getQianMonth(0).substring(0, 10);
			String x1 = DateUtil.getQianMonth(1).substring(0, 10);
			String x2 = DateUtil.getQianMonth(2).substring(0, 10);
			String x3 = DateUtil.getQianMonth(3).substring(0, 10);
			String x4 = DateUtil.getQianMonth(4).substring(0, 10);
			String x5 = DateUtil.getQianMonth(5).substring(0, 10);
			String x6 = DateUtil.getQianMonth(6).substring(0, 10);
			String x7 = DateUtil.getQianMonth(7).substring(0, 10);
			String x8 = DateUtil.getQianMonth(8).substring(0, 10);
			String x9 = DateUtil.getQianMonth(9).substring(0, 10);
			String x10 = DateUtil.getQianMonth(10).substring(0, 10);
			String x11 = DateUtil.getQianMonth(11).substring(0, 10);
			String x12 = DateUtil.getQianMonth(12).substring(0, 10);

			accessTimeVo.setSt12(x0.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd12(xx.substring(0, 7) + "-01 00:00:00");


			accessTimeVo.setSt11(x1.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd11(x0.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt10(x2.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd10(x1.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt9(x3.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd9(x2.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt8(x4.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd8(x3.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt7(x5.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd7(x4.substring(0, 7) + "-01 00:00:00");


			accessTimeVo.setSt6(x6.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd6(x5.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt5(x7.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd5(x6.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt4(x8.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd4(x7.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt3(x9.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd3(x8.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt2(x10.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd2(x9.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt1(x11.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd1(x10.substring(0, 7) + "-01 00:00:00");

			Map<String, String> map1 = xmssIdeaMapper.selectTimeByBan(accessTimeVo);
			Map<String, String> map2 = xmssIdeaMapper.selectTimeByNoBan(accessTimeVo);

			for (int i = 1; i < 13; i++) {
				String  temp = DateUtil.getQianMonth(12 - (i)).substring(0, 7);
				if (map1 != null) {
					dt.put(temp, map1.get("t" + i));
				} else {
					dt.put(temp, 0);
				}
				if (map2 != null) {
					dt1.put(temp, map2.get("t" + i));
				} else {
					dt1.put(temp, 0);
				}
				/*dt.put("time", DateUtil.getQianMonth(12 - (i)).substring(0, 7).replaceAll("-", "/"));
				result.add(dt);*/

				time.add(temp);

			}
			result.add(dt);
			result.add(dt1);
			map.put("data", result);
			map.put("time", time);
		}
		return map;
    }

	@Override
	public Map<String ,Object> pjData(int type ,int personType) {
        if(personType == 0){
            personType =1;
        }
		Map<String, Object> map = new HashMap<>();

		map.put("success", true);
		map.put("message", "操作成功!");
		map.put("code", "200");
		List<Object> result = new ArrayList<>();
		List<Object> time = new ArrayList<>();
		String now = DateUtil.getTime();
		//周
		Map<String, Object> dt = null;
		Map<String, Object> dt1 = null;
		Map<String, Object> dt2 = null;
		Map<String, Object> dt3 = null;
		Map<String, Object> dt4 = null;
		dt = new HashMap<>();
		dt.put("name", "一星");
		dt1 = new HashMap<>();
		dt1.put("name", "二星");
		dt2 = new HashMap<>();
		dt2.put("name", "三星");
		dt3 = new HashMap<>();
		dt3.put("name", "四星");
		dt4 = new HashMap<>();
		dt4.put("name", "五星");
		AccessTimeVo accessTimeVo = new AccessTimeVo();
		accessTimeVo.setPersonType(personType);
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		accessTimeVo.setAreaCode(sysUser.getRelTenantIds());
		if (type == 1) {
			String x0 = DateUtil.getQianXday(0).substring(0, 10);
			String x1 = DateUtil.getQianXday(1).substring(0, 10);
			String x2 = DateUtil.getQianXday(2).substring(0, 10);
			String x3 = DateUtil.getQianXday(3).substring(0, 10);
			String x4 = DateUtil.getQianXday(4).substring(0, 10);
			String x5 = DateUtil.getQianXday(5).substring(0, 10);
			String x6 = DateUtil.getQianXday(6).substring(0, 10);

			accessTimeVo.setSt7(x6 + " 00:00:00");
			accessTimeVo.setEnd7(x6 + " 23:59:59");
			accessTimeVo.setSt6(x5 + " 00:00:00");
			accessTimeVo.setEnd6(x5 + " 23:59:59");
			accessTimeVo.setSt5(x4 + " 00:00:00");
			accessTimeVo.setEnd5(x4 + " 23:59:59");
			accessTimeVo.setSt4(x3 + " 00:00:00");
			accessTimeVo.setEnd4(x3 + " 23:59:59");
			accessTimeVo.setSt3(x2 + " 00:00:00");
			accessTimeVo.setEnd3(x2 + " 23:59:59");
			accessTimeVo.setSt2(x1 + " 00:00:00");
			accessTimeVo.setEnd2(x1 + " 23:59:59");
			accessTimeVo.setSt1(x0 + " 00:00:00");
			accessTimeVo.setEnd1(x0 + " 23:59:59");

			accessTimeVo.setStar(1);
			Map<String, String> map1 = xmssIdeaMapper.selectTimeByYes(accessTimeVo);
			accessTimeVo.setStar(2);
			Map<String, String> map2 = xmssIdeaMapper.selectTimeByYes(accessTimeVo);
			accessTimeVo.setStar(3);
			Map<String, String> map3 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);
			accessTimeVo.setStar(4);
			Map<String, String> map4 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);
			accessTimeVo.setStar(5);
			Map<String, String> map5 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);

			for (int i = 7; i > 0; i--) {

				if (map1 != null) {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), map1.get("t" + i));
				} else {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map2 != null) {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), map2.get("t" + i));
				} else {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map3 != null) {
					dt2.put(DateUtil.getQianXday(i-1).substring(5, 10), map3.get("t" + i));
				} else {
					dt2.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map4 != null) {
					dt3.put(DateUtil.getQianXday(i-1).substring(5, 10), map4.get("t" + i));
				} else {
					dt3.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map5 != null) {
					dt4.put(DateUtil.getQianXday(i-1).substring(5, 10), map5.get("t" + i));
				} else {
					dt4.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				//dt.put("time", DateUtil.getQianXday(i).substring(5, 10));
				time.add(DateUtil.getQianXday(i-1).substring(5, 10));
			}
			result.add(dt);
			result.add(dt1);
			result.add(dt2);
			result.add(dt3);
			result.add(dt4);
			map.put("data", result);
			map.put("time", time);

		}

		//月
		if (type == 2) {

			String x0 = DateUtil.getQianXday(0).substring(0, 10);
			String x1 = DateUtil.getQianXday(1).substring(0, 10);
			String x2 = DateUtil.getQianXday(2).substring(0, 10);
			String x3 = DateUtil.getQianXday(3).substring(0, 10);
			String x4 = DateUtil.getQianXday(4).substring(0, 10);
			String x5 = DateUtil.getQianXday(5).substring(0, 10);
			String x6 = DateUtil.getQianXday(6).substring(0, 10);
			String x7 = DateUtil.getQianXday(7).substring(0, 10);
			String x8 = DateUtil.getQianXday(8).substring(0, 10);
			String x9 = DateUtil.getQianXday(9).substring(0, 10);
			String x10 = DateUtil.getQianXday(10).substring(0, 10);
			String x11 = DateUtil.getQianXday(11).substring(0, 10);
			String x12 = DateUtil.getQianXday(12).substring(0, 10);
			String x13 = DateUtil.getQianXday(13).substring(0, 10);
			String x14 = DateUtil.getQianXday(14).substring(0, 10);
			String x15 = DateUtil.getQianXday(15).substring(0, 10);
			String x16 = DateUtil.getQianXday(16).substring(0, 10);
			String x17 = DateUtil.getQianXday(17).substring(0, 10);
			String x18 = DateUtil.getQianXday(18).substring(0, 10);
			String x19 = DateUtil.getQianXday(19).substring(0, 10);
			String x20 = DateUtil.getQianXday(20).substring(0, 10);
			String x21 = DateUtil.getQianXday(21).substring(0, 10);
			String x22 = DateUtil.getQianXday(22).substring(0, 10);
			String x23 = DateUtil.getQianXday(23).substring(0, 10);
			String x24 = DateUtil.getQianXday(24).substring(0, 10);
			String x25 = DateUtil.getQianXday(25).substring(0, 10);
			String x26 = DateUtil.getQianXday(26).substring(0, 10);
			String x27 = DateUtil.getQianXday(27).substring(0, 10);
			String x28 = DateUtil.getQianXday(28).substring(0, 10);
			String x29 = DateUtil.getQianXday(29).substring(0, 10);
			String x30 = DateUtil.getQianXday(30).substring(0, 10);
			String x31 = DateUtil.getQianXday(30).substring(0, 10);

			accessTimeVo.setSt31(x30 + " 00:00:00");
			accessTimeVo.setEnd31(x30 + " 23:59:59");
			accessTimeVo.setSt30(x29 + " 00:00:00");
			accessTimeVo.setEnd30(x29 + " 23:59:59");
			accessTimeVo.setSt29(x28 + " 00:00:00");
			accessTimeVo.setEnd29(x28 + " 23:59:59");
			accessTimeVo.setSt28(x27 + " 00:00:00");
			accessTimeVo.setEnd28(x27 + " 23:59:59");
			accessTimeVo.setSt27(x26 + " 00:00:00");
			accessTimeVo.setEnd27(x26 + " 23:59:59");
			accessTimeVo.setSt26(x25 + " 00:00:00");
			accessTimeVo.setEnd26(x25 + " 23:59:59");
			accessTimeVo.setSt25(x24 + " 00:00:00");
			accessTimeVo.setEnd25(x24 + " 23:59:59");
			accessTimeVo.setSt24(x23 + " 00:00:00");
			accessTimeVo.setEnd24(x23 + " 23:59:59");
			accessTimeVo.setSt23(x22 + " 00:00:00");
			accessTimeVo.setEnd23(x22 + " 23:59:59");
			accessTimeVo.setSt22(x21 + " 00:00:00");
			accessTimeVo.setEnd22(x21 + " 23:59:59");
			accessTimeVo.setSt21(x20 + " 00:00:00");
			accessTimeVo.setEnd21(x20 + " 23:59:59");
			accessTimeVo.setSt20(x19 + " 00:00:00");
			accessTimeVo.setEnd20(x19 + " 23:59:59");


			accessTimeVo.setSt19(x18 + " 00:00:00");
			accessTimeVo.setEnd19(x18 + " 23:59:59");
			accessTimeVo.setSt18(x17 + " 00:00:00");
			accessTimeVo.setEnd18(x17 + " 23:59:59");
			accessTimeVo.setSt17(x16 + " 00:00:00");
			accessTimeVo.setEnd17(x16 + " 23:59:59");
			accessTimeVo.setSt16(x15 + " 00:00:00");
			accessTimeVo.setEnd16(x15 + " 23:59:59");
			accessTimeVo.setSt15(x14 + " 00:00:00");
			accessTimeVo.setEnd15(x14 + " 23:59:59");
			accessTimeVo.setSt14(x13 + " 00:00:00");
			accessTimeVo.setEnd14(x13 + " 23:59:59");
			accessTimeVo.setSt13(x12 + " 00:00:00");
			accessTimeVo.setEnd13(x12 + " 23:59:59");
			accessTimeVo.setSt12(x11 + " 00:00:00");
			accessTimeVo.setEnd12(x11 + " 23:59:59");
			accessTimeVo.setSt11(x10 + " 00:00:00");
			accessTimeVo.setEnd11(x10 + " 23:59:59");
			accessTimeVo.setSt10(x9 + " 00:00:00");
			accessTimeVo.setEnd10(x9 + " 23:59:59");


			accessTimeVo.setSt9(x8 + " 00:00:00");
			accessTimeVo.setEnd9(x8 + " 23:59:59");
			accessTimeVo.setSt8(x7 + " 00:00:00");
			accessTimeVo.setEnd8(x7 + " 23:59:59");
			accessTimeVo.setSt7(x6 + " 00:00:00");
			accessTimeVo.setEnd7(x6 + " 23:59:59");
			accessTimeVo.setSt6(x5 + " 00:00:00");
			accessTimeVo.setEnd6(x5 + " 23:59:59");
			accessTimeVo.setSt5(x4 + " 00:00:00");
			accessTimeVo.setEnd5(x4 + " 23:59:59");
			accessTimeVo.setSt4(x3 + " 00:00:00");
			accessTimeVo.setEnd4(x3 + " 23:59:59");
			accessTimeVo.setSt3(x2 + " 00:00:00");
			accessTimeVo.setEnd3(x2 + " 23:59:59");
			accessTimeVo.setSt2(x1 + " 00:00:00");
			accessTimeVo.setEnd2(x1 + " 23:59:59");
			accessTimeVo.setSt1(x0 + " 00:00:00");
			accessTimeVo.setEnd1(x0 + " 23:59:59");


			accessTimeVo.setStar(1);
			Map<String, String> map1 = xmssIdeaMapper.selectTimeByYes(accessTimeVo);
			accessTimeVo.setStar(2);
			Map<String, String> map2 = xmssIdeaMapper.selectTimeByYes(accessTimeVo);
			accessTimeVo.setStar(3);
			Map<String, String> map3 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);
			accessTimeVo.setStar(4);
			Map<String, String> map4 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);
			accessTimeVo.setStar(5);
			Map<String, String> map5 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);

			for (int i = 31; i > 0; i--) {
				if (map1 != null) {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), map1.get("t" + i));
				} else {
					dt.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map2 != null) {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), map2.get("t" + i));
				} else {
					dt1.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map3 != null) {
					dt2.put(DateUtil.getQianXday(i-1).substring(5, 10), map3.get("t" + i));
				} else {
					dt2.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map4 != null) {
					dt3.put(DateUtil.getQianXday(i-1).substring(5, 10), map4.get("t" + i));
				} else {
					dt3.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				if (map5 != null) {
					dt4.put(DateUtil.getQianXday(i-1).substring(5, 10), map5.get("t" + i));
				} else {
					dt4.put(DateUtil.getQianXday(i-1).substring(5, 10), 0);
				}
				//dt.put("time", DateUtil.getQianXday(i).substring(5, 10));
				time.add(DateUtil.getQianXday(i-1).substring(5, 10));
			}
			result.add(dt);
			result.add(dt1);
			result.add(dt2);
			result.add(dt3);
			result.add(dt4);
			map.put("data", result);
			map.put("time", time);
		}

		if (type == 3) {
			String xx = DateUtil.getQianMonth(-1).substring(0, 10);
			String x0 = DateUtil.getQianMonth(0).substring(0, 10);
			String x1 = DateUtil.getQianMonth(1).substring(0, 10);
			String x2 = DateUtil.getQianMonth(2).substring(0, 10);
			String x3 = DateUtil.getQianMonth(3).substring(0, 10);
			String x4 = DateUtil.getQianMonth(4).substring(0, 10);
			String x5 = DateUtil.getQianMonth(5).substring(0, 10);
			String x6 = DateUtil.getQianMonth(6).substring(0, 10);
			String x7 = DateUtil.getQianMonth(7).substring(0, 10);
			String x8 = DateUtil.getQianMonth(8).substring(0, 10);
			String x9 = DateUtil.getQianMonth(9).substring(0, 10);
			String x10 = DateUtil.getQianMonth(10).substring(0, 10);
			String x11 = DateUtil.getQianMonth(11).substring(0, 10);
			String x12 = DateUtil.getQianMonth(12).substring(0, 10);

			accessTimeVo.setSt12(x0.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd12(xx.substring(0, 7) + "-01 00:00:00");


			accessTimeVo.setSt11(x1.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd11(x0.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt10(x2.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd10(x1.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt9(x3.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd9(x2.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt8(x4.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd8(x3.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt7(x5.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd7(x4.substring(0, 7) + "-01 00:00:00");


			accessTimeVo.setSt6(x6.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd6(x5.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt5(x7.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd5(x6.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt4(x8.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd4(x7.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt3(x9.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd3(x8.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt2(x10.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd2(x9.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setSt1(x11.substring(0, 7) + "-01 00:00:00");
			accessTimeVo.setEnd1(x10.substring(0, 7) + "-01 00:00:00");

			accessTimeVo.setStar(1);
			Map<String, String> map1 = xmssIdeaMapper.selectTimeByYes(accessTimeVo);
			accessTimeVo.setStar(2);
			Map<String, String> map2 = xmssIdeaMapper.selectTimeByYes(accessTimeVo);
			accessTimeVo.setStar(3);
			Map<String, String> map3 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);
			accessTimeVo.setStar(4);
			Map<String, String> map4 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);
			accessTimeVo.setStar(5);
			Map<String, String> map5 = xmssIdeaMapper.selectTimeByGeneral(accessTimeVo);

			for (int i = 1; i < 13; i++) {
				String  temp = DateUtil.getQianMonth(12 - (i)).substring(0, 7);
				if (map1 != null) {
					dt.put(temp, map1.get("t" + i));
				} else {
					dt.put(temp, 0);
				}
				if (map2 != null) {
					dt1.put(temp, map2.get("t" + i));
				} else {
					dt1.put(temp, 0);
				}
				if (map3 != null) {
					dt2.put(temp, map3.get("t" + i));
				} else {
					dt2.put(temp, 0);
				}
				if (map4 != null) {
					dt3.put(temp, map4.get("t" + i));
				} else {
					dt3.put(temp, 0);
				}
				if (map5 != null) {
					dt4.put(temp, map5.get("t" + i));
				} else {
					dt4.put(temp, 0);
				}
				/*dt.put("time", DateUtil.getQianMonth(12 - (i)).substring(0, 7).replaceAll("-", "/"));
				result.add(dt);*/
				time.add(temp);

			}
			result.add(dt);
			result.add(dt1);
			result.add(dt2);
			result.add(dt3);
			result.add(dt4);
			map.put("data", result);
			map.put("time", time);
		}
		return map;
	}

	@Override
	public Map<String, Object> indexData() {
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		Map<String, Object> map = new HashMap<>();
		String time = DateUtil.getTime().substring(0, 10) + " 00:00:00";
		LambdaQueryWrapper<XmssIdea> queryWrapper = new LambdaQueryWrapper<>();//今日已办
		queryWrapper.ge(XmssIdea::getAnswerTime, time);
		queryWrapper.ge(XmssIdea::getAppState,3);//大于等于3 已处理
		if(StringUtils.isNotEmpty(sysUser.getRelTenantIds())){
			queryWrapper.eq(XmssIdea::getTownsId, sysUser.getRelTenantIds());
		}
		map.put("todayFinish",baseMapper.selectCount(queryWrapper));

		LambdaQueryWrapper<XmssIdea> todo = new LambdaQueryWrapper<>();//待处理
		todo.eq(XmssIdea::getAppState,1);
		if(StringUtils.isNotEmpty(sysUser.getRelTenantIds())){
			todo.eq(XmssIdea::getTownsId, sysUser.getRelTenantIds());
		}
		map.put("todo",baseMapper.selectCount(todo));//待处理

		LambdaQueryWrapper<XmssIdea> finish = new LambdaQueryWrapper<>();//已完成
		finish.ge(XmssIdea::getAppState,3);
		if(StringUtils.isNotEmpty(sysUser.getRelTenantIds())){
			finish.eq(XmssIdea::getTownsId, sysUser.getRelTenantIds());
		}
		map.put("finish",baseMapper.selectCount(finish));

		LambdaQueryWrapper<XmssIdea> evaluate = new LambdaQueryWrapper<>();//好评
		evaluate.eq(XmssIdea::getAppState,4);
		evaluate.eq(XmssIdea::getSupervise,2);
		if(StringUtils.isNotEmpty(sysUser.getRelTenantIds())){
			evaluate.eq(XmssIdea::getTownsId, sysUser.getRelTenantIds());
		}
		map.put("yes",baseMapper.selectCount(evaluate));
		return map;
	}

	@Override
	public Map<String ,Object> indexIdeaData() {
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		Map<String, Object> map = new HashMap<>();
		LambdaQueryWrapper<XmssIdea> queryWrapper = new LambdaQueryWrapper<>();
		if(StringUtils.isNotEmpty(sysUser.getRelTenantIds())){
			queryWrapper.eq(XmssIdea::getTownsId, sysUser.getRelTenantIds());
		}
		map.put("ideaCount", baseMapper.selectCount(queryWrapper));
		map.put("success", true);
		map.put("message", "操作成功!");
		map.put("code", "200");
		List<Object> result = new ArrayList<>();
		String now = DateUtil.getTime();
		//周
		Map<String, Object> dt = null;
		AccessTimeVo accessTimeVo = new AccessTimeVo();
		accessTimeVo.setAreaCode(sysUser.getRelTenantIds());
		String xx = DateUtil.getQianMonth(-1).substring(0, 10);
		String x0 = DateUtil.getQianMonth(0).substring(0, 10);
		String x1 = DateUtil.getQianMonth(1).substring(0, 10);
		String x2 = DateUtil.getQianMonth(2).substring(0, 10);
		String x3 = DateUtil.getQianMonth(3).substring(0, 10);
		String x4 = DateUtil.getQianMonth(4).substring(0, 10);
		String x5 = DateUtil.getQianMonth(5).substring(0, 10);
		String x6 = DateUtil.getQianMonth(6).substring(0, 10);
		String x7 = DateUtil.getQianMonth(7).substring(0, 10);
		String x8 = DateUtil.getQianMonth(8).substring(0, 10);
		String x9 = DateUtil.getQianMonth(9).substring(0, 10);
		String x10 = DateUtil.getQianMonth(10).substring(0, 10);
		String x11 = DateUtil.getQianMonth(11).substring(0, 10);
		String x12 = DateUtil.getQianMonth(12).substring(0, 10);

		accessTimeVo.setSt12(x0.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd12(xx.substring(0, 7) + "-01 00:00:00");


		accessTimeVo.setSt11(x1.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd11(x0.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt10(x2.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd10(x1.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt9(x3.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd9(x2.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt8(x4.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd8(x3.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt7(x5.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd7(x4.substring(0, 7) + "-01 00:00:00");


		accessTimeVo.setSt6(x6.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd6(x5.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt5(x7.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd5(x6.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt4(x8.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd4(x7.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt3(x9.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd3(x8.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt2(x10.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd2(x9.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setSt1(x11.substring(0, 7) + "-01 00:00:00");
		accessTimeVo.setEnd1(x10.substring(0, 7) + "-01 00:00:00");

		Map<String, String> map1 = xmssIdeaMapper.selectByMonth(accessTimeVo);

		for (int i = 1; i < 13; i++) {
			dt = new HashMap<>();
			if (map1 != null) {
				dt.put("数量", map1.get("t" + i));
				dt.put("country", "Asia");
			} else {
				dt.put("数量", "0");
				dt.put("country", "Asia");
			}
			dt.put("year", DateUtil.getQianMonth(12 - (i)).substring(0, 7).replaceAll("-", "/"));
			result.add(dt);
		}
		map.put("list", result);
		return map;
	}

    @Override
    public IPage<XmssIdea> personIdea(String userId,Integer pageNo ,Integer pageSize) {
		Page<XmssIdea> page = null;
		if(pageNo == null){
			page = new Page<>(1, 10);
		}else {
			page = new Page<>(pageNo, pageSize);
		}
		IPage<XmssIdea> pageList = xmssIdeaMapper.selectIdeaByPersonBig(page,userId);

        return pageList;
    }

	@Override
	public IPage<XmssIdea> jbIdea(String userId,Integer pageNo ,Integer pageSize) {
		Page<XmssIdea> page = null;
		if(pageNo == null){
			page = new Page<>(1, 10);
		}else {
			page = new Page<>(pageNo, pageSize);
		}
		IPage<XmssIdea> pageList = xmssIdeaMapper.selectIdeaByPersonJb(page,userId);

		return pageList;
	}


    @Override
    public void downWords(HttpServletRequest request, HttpServletResponse response) {
        String ids = request.getParameter("ids");
        Assert.notNull(ids, "记录id不能为空");
        List<String> list = Arrays.asList(ids.split(","));
        if (list.size() > 1) {
            List<XmssIdea> xmssIdea = baseMapper.selectBatchIds(list);
            xmssIdea.stream().forEach(e -> {
                Map<String, Object> map = new HashMap<>(20);
                map.put("name", e.getName());
                map.put("mobile", e.getMobile());
                String tempUrl = dirPath + "/aa.docx";
                FileUtils.exportWord2(tempUrl, dirPath, e.getName() + "-" + e.getId() + ".docx", map, request, response);
            });
            ZipUtil.zip(dirPath, "D:\\opt\\bbb\\aaa.zip");
            String fileUrl = "D:\\opt\\smss\\aaa.zip";
            ServletOutputStream outputStream = null;
            try {
                outputStream = response.getOutputStream();
                response.setContentType("application/force-download");
                //        设置编码，避免文件名中文乱码
                response.setHeader("Content-Disposition", "attachment;filename=" + new String("aaa.zip".toString().getBytes("gb2312"), "ISO8859-1"));
                outputStream.write(FileUtil.readBytes(fileUrl));
                IoUtil.close(outputStream);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            XmssIdea e = baseMapper.selectById(list.get(0));
            List<XmssSupervise> selectSupervise = xmssSuperviseMapper.selectByIds(e.getId());
            SysUser selectSysUser=null;
            if(selectSupervise.size()!=0) {
                selectSysUser = xmssSuperviseMapper.selectUserId(selectSupervise.get(0).getUserId());
            }
            String dafen1="";
            String dafen2="";
            String dafen3="";
            String dafen4="";
            switch (e.getSupervise()) {
                case 0:
                    dafen1="√";
                    break;
                case 1:
                    dafen2="√";
                    break;
                case 2:
                    dafen3="√";
                    break;
                case 3:
                    dafen4="√";
                    break;

            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Map<String, Object> map = new HashMap<>(20);
            map.put("name", e.getName());
            map.put("mobile", e.getMobile());
            map.put("createTime", sdf.format(e.getCreateTime()));
            map.put("idea", e.getIdea());
            map.put("answer", e.getAnswer()!=null ?e.getAnswer() :"");
            map.put("id", e.getId());
            map.put("updateTime", sdf.format(e.getUpdateTime()));
            map.put("dafen1", dafen1);
            map.put("dafen2", dafen2);
            map.put("dafen3", dafen3);
            map.put("dafen4", dafen4);
            map.put("names", selectSysUser!=null ?  selectSysUser.getRealname():"");
            map.put("time", selectSupervise.size()!=0 ? sdf.format(selectSupervise.get(0).getCreateTime()):"");
            String tempUrl = dirPath + "/aa.docx";
            SysOperationLogPage getSysOperationLogPage=new SysOperationLogPage();
            getSysOperationLogPage.setLogContent("下载模板");
            getSysOperationLogPage.setOperationContent("下载了"+e.getId()+"编号日记");
            sysOperationLogController.add(getSysOperationLogPage);
            FileUtils.exportWord(tempUrl, dirPath, e.getName() + ".docx", map, request, response);
        }
    }


}
